﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Admin.Core.Common.Input;
using Admin.Core.Common.Output;
using Admin.Core.Common.ParamInput;
using Admin.Core.Service.Warehouse.StockIn;
using Admin.Core.Service.Warehouse.StockIn.Input;
using Admin.Core.Service.Warehouse.XbcMeterrial;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Admin.Core.Controllers.Warehouse
{
    public class StockInController : AreaController
    {
        private readonly IXbcMaterrialService _xbcMaterrialService;
        private readonly IStockInService _stockInService;

        public StockInController(IXbcMaterrialService xbcMaterrialService, IStockInService stockInService)
        {
            _xbcMaterrialService = xbcMaterrialService;
            _stockInService = stockInService;
        }

        /// <summary>
        /// 分页查询库存入库信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IResponseOutput> GetPage(PageInput<StockInFilterInput> model)
        {
            return await _stockInService.PageAsync(model);
        }

        /// <summary>
        /// 根据物料id获取物料号下拉
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<IResponseOutput> GetMaterList(long id)
        {
            return await _xbcMaterrialService.GetMaterListAsync(id);
        }


        /// <summary>
        /// 根据物料id物料规格信息
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<IResponseOutput> GetMaterInfo(long id)
        {
            return await _xbcMaterrialService.GetMaterDetailAsync(id);
        }

        /// <summary>
        /// 新增入库
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IResponseOutput> Add(List<StockInAddInput> input)
        {
            return await _stockInService.AddAsync(input);
        }



    }
}